package com.atelier.plugin.pjavafx;

import com.intellij.diff.DiffContentFactory;
import com.intellij.diff.DiffManagerEx;
import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.contents.FileContentImpl;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileChooser.FileSystemTree;
import com.intellij.openapi.fileChooser.FileSystemTreeFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.project.MavenWorkspaceSettings;


import javax.swing.*;
import java.io.File;

public class DiffTest extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {

        /**
         * 代码对比测试
         */
        Project project = e.getProject();
    //    File file = new File("D:\\code8\\Atelier\\src\\test\\java\\com\\sjhy\\plugin\\diffTest\\DiffTest.java");
    //    File file1 = new File("D:\\code8\\Atelier\\src\\test\\java\\com\\sjhy\\plugin\\MinTest.java");
    //    VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(file);
    //    VirtualFile fileByIoFile1 = LocalFileSystem.getInstance().findFileByIoFile(file1);
    //    DiffContentFactory contentFactory = DiffContentFactory.getInstance();
    //     DiffContent diffContent = contentFactory.create(project, fileByIoFile);
    //     DiffContent diffContent1 = contentFactory.create(project, fileByIoFile1);
    //    SimpleDiffRequest simpleDiffRequest = new SimpleDiffRequest("文件对比", diffContent, diffContent1, "file1", "file2");
    //    DiffManagerEx.getInstance().showDiff(project, simpleDiffRequest);
    //


         FileSystemTreeFactory instance = FileSystemTreeFactory.SERVICE.getInstance();
         FileChooserDescriptor multipleJavaPathDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
         FileSystemTree fileSystemTree = instance.createFileSystemTree(project, multipleJavaPathDescriptor);
         JTree tree = fileSystemTree.getTree();
         tree.show();
    }
}
